package com.shanzmoo.admin.web.store;

import com.shanzmoo.admin.domain.dto.StoreReceivePutawayUpdateDTO;
import com.shanzmoo.admin.manager.store.StoreReceivePutawayManager;
import com.shanzmoo.base.bean.SResponse;
import com.shanzmoo.core.cache.CurrentUserCache;
import com.shanzmoo.db.store.entity.query.StoreReceivePutawayQuery;
import com.shanzmoo.db.store.entity.vo.StoreReceivePutawayVO;
import com.shanzmoo.base.bean.PageRespBase;
import com.shanzmoo.base.bean.SHttpResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.web.bind.annotation.*;
import org.springframework.beans.factory.annotation.Autowired;

import javax.validation.Valid;

/**
 * 仓库收货上架信息 控制层
 *
 * @author Gzhao 2021-03-11
 */
@Api(tags = "仓库-上架")
@RestController
@RequestMapping("/store/receive-putaway")
public class StoreReceivePutawayController {

    @Autowired
    private StoreReceivePutawayManager storeReceivePutawayManager;

    @ApiOperation(value = "分页列表")
    @PostMapping("/pageList")
    public SHttpResponse<PageRespBase<StoreReceivePutawayVO>> pageList(@Valid @RequestBody StoreReceivePutawayQuery query) {
        PageRespBase<StoreReceivePutawayVO> pageList = storeReceivePutawayManager.queryPage(query);
        return SHttpResponse.ok(pageList);
    }

    @ApiOperation(value = "上架")
    @PostMapping("/putaway")
    public SHttpResponse<Boolean> putaway(@Valid @RequestBody StoreReceivePutawayUpdateDTO updateDto) {
        SResponse<Boolean> re = storeReceivePutawayManager.putaway(updateDto, CurrentUserCache.getUserId());
        return SHttpResponse.transform(re);
    }
 }
